<!-- 前台我的信息 -->
<template>
    <div class="myinfo-container">
      <el-empty v-if="remarks === ''" description="请先登录或注册" class="empty_style"></el-empty>
      <el-descriptions v-if="remarks === '用户'" class="margin-top" title="我的个人信息（可查看）" :column="3" size="small" border>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user"></i>
            账号
          </template>
          {{userAccount}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user-solid"></i>
            姓名
          </template>
          {{userName}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user-solid"></i>
            性别
          </template>
          {{userSex}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            身份证
          </template>
          {{userIdNumber}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            婚姻状态
          </template>
          {{userIsMarried}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            联系电话
          </template>
          {{userPhone}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-location-outline"></i>
            邮箱
          </template>
          {{userEmail}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            备注
          </template>
          <el-tag size="small">用户</el-tag>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            注册时间
          </template>
          {{userRegisterDate}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            联系地址
          </template>
          {{userAddress}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            说明
          </template>
          修改个人信息请前往后台☝
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions v-if="remarks === '企业'" class="margin-top" title="企业目前信息（可查看）" :column="3" size="small" border>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user"></i>
            企业账号
          </template>
          {{companyAccount}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user-solid"></i>
            企业名称
          </template>
          {{companyName}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user-solid"></i>
            企业联系人
          </template>
          {{companyLeader}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            企业联系电话
          </template>
          {{companyPhone}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            企业邮箱
          </template>
          {{companyEmail}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            企业地址
          </template>
          {{companyAddress}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            备注
          </template>
          <el-tag size="small">{{remarks}}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            企业注册时间
          </template>
          {{companyRegisterDate}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            说明
          </template>
          修改个人信息请前往后台☝
        </el-descriptions-item>
      </el-descriptions>
      <el-empty v-if="remarks === '管理员'" description="您的角色是管理员，个人信息请前往后台查看。" class="empty_style"></el-empty>
    </div>
</template>

<script>
import { getStore } from '../../../storage/storage';
import { getCompanyOrUserAllInfo } from '../../../api/personalApi/index';
export default {
    name: 'myInfo',
  data () {
    return {
      remarks: '',
      userAccount:'',
      userName: '',
      userSex: '',
      userIdNumber: '',
      userIsMarried: '',
      userPhone: '',
      userEmail: '',
      userRegisterDate: '',
      userAddress: '',
      companyAccount: '',
      companyName:'',
      companyLeader: '',
      companyPhone: '',
      companyEmail: '',
      companyAddress: '',
      companyRegisterDate: '',
    }
  },
  created(){
    this.currentLoginUserOrCompanyAllInfo();
  },
  methods:{
    currentLoginUserOrCompanyAllInfo(){ // 获取当前登录用户或企业的全部信息
      if(getStore("account") === null){
        this.remarks = '';
      }
      const params = {
        account: getStore("account"),
      }

      getCompanyOrUserAllInfo(params).then(res=>{
        const resultData = res.data.data;
        this.remarks = resultData.remarks;
        this.userAccount = resultData.userAccount;
        this.userName = resultData.userName;
        this.userSex = resultData.userSex;
        this.userIdNumber = resultData.userIdNumber;
        this.userIsMarried = resultData.userIsMarried;
        this.userPhone = resultData.userPhone;
        this.userEmail = resultData.userEmail;
        this.userRegisterDate = resultData.userRegisterDate;
        this.userAddress = resultData.userAddress;
        this.companyAccount = resultData.companyAccount;
        this.companyName = resultData.companyName;
        this.companyLeader = resultData.companyLeader;
        this.companyPhone = resultData.companyPhone;
        this.companyEmail = resultData.companyEmail;
        this.companyAddress = resultData.companyAddress;
        this.companyRegisterDate = resultData.companyRegisterDate;
      })

      
    }
  },
}
</script>

<style scoped>
@import '../../../assets/css/reception/myInfo.css';
</style>
